
#pragma once

#include "zacdocman.h"
#include <map>

template <class T> 
class UcApDataManager : public UcApDocManagerReactor {

public:
	UcApDataManager () {
		ucDocManager->addReactor (this) ;
	}
	~UcApDataManager () {
		if ( ucDocManager != NULL )
			ucDocManager->removeReactor (this) ;
	}
	virtual void documentToBeDestroyed (UcApDocument *pDoc) {
		m_dataMap.erase (pDoc) ;
	}

	T &docData (UcApDocument *pDoc) {
		if (m_dataMap.find(pDoc) == m_dataMap.end ())
			return (m_dataMap[pDoc]) ;
		return ((*(m_dataMap.find(pDoc))).second);
	}
	T &docData () {
		return (docData (ucDocManager->curDocument ())) ;
	}

private:
	std::map<UcApDocument *, T> m_dataMap ;
} ;
